package com.chuji.crmcj.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chuji.crmcj.R;

/**
 * Created by w.pitt on 2016/1/19.
 */
public class InsureBar extends RelativeLayout {

    private TextView mTvTitle;
    private CheckBox iv_check1;
    private TextView tv_cost;
    private LinearLayout mRight;

    public InsureBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context, attrs);
    }

    public InsureBar(Context context) {

        this(context, null);
    }

    public InsureBar(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs);
    }

    private void initView(Context context, AttributeSet attrs) {
        View child = View.inflate(getContext(), R.layout.layout_insure, null);
        mTvTitle = (TextView) child.findViewById(R.id.tv_extra_name1);
        iv_check1 = (CheckBox) child.findViewById(R.id.iv_check1);
        tv_cost = (TextView) child.findViewById(R.id.tv_extra_cost1);
        mRight = (LinearLayout) child.findViewById(R.id.iv_right_icon);
        this.addView(child);

        // 读取刚刚我们定义的属性
        // 第一个参数：属性
        // 第二个参数：属性的数组
        TypedArray ta = context.obtainStyledAttributes(attrs,
                R.styleable.InsureItem);
        String title = ta.getString(R.styleable.InsureItem_title);
//        Drawable drawable = ta.getDrawable(R.styleable.SettingItemView_itbackground);
//        String time = ta.getString(R.styleable.SettingItemView_time);
        ta.recycle();
        mTvTitle.setText(title);
    }

    public CheckBox getCheck() {
        return iv_check1;
    }

    public TextView getInsCost() {
        return tv_cost;
    }

    public LinearLayout getLlRightIcon() {
        return mRight;
    }

}
